package com.xn.app.muying.activity;

import android.app.AlertDialog;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.xn.app.muying.R;
import com.xn.app.muying.fragment.KePuManFragment;
import com.xn.app.muying.fragment.KePuWomanFragment;
import com.xn.app.muying.util.MyAlertDialog;

/**
 * Created by Administrator on 2016/10/13.
 */
public class KePuActivity extends AppCompatActivity implements View.OnClickListener {

    private TextView kepu_womam;
    private TextView kepu_mam;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_kepu);
        kepu_womam = (TextView) findViewById(R.id.kepu_activity_woman_tv);
        kepu_mam = (TextView) findViewById(R.id.kepu_activity_man_tv);
        ImageView back = (ImageView) findViewById(R.id.kepu_activity_back);
        kepu_womam.setOnClickListener(this);
        kepu_mam.setOnClickListener(this);
        back.setOnClickListener(this);
        KePuWomanFragment kepuwomanfragment = new KePuWomanFragment();
        replace(kepuwomanfragment);


    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.kepu_activity_woman_tv:
                KePuWomanFragment kepuwomanfragment = new KePuWomanFragment();
                replace(kepuwomanfragment);
                kepu_womam.setBackgroundResource(R.drawable.button_red_kepu1);
                kepu_mam.setBackgroundResource(R.drawable.button_white_kepu2);
                kepu_womam.setText("女性检查项目");
                kepu_womam.setTextColor(getResources().getColor(R.color.white));
                kepu_mam.setText("男性检查项目");
                kepu_mam.setTextColor(getResources().getColor(R.color.sys_fen));
                break;
            case R.id.kepu_activity_man_tv:
                KePuManFragment kepumanfragment = new KePuManFragment();
                replace(kepumanfragment);
                kepu_mam.setBackgroundResource(R.drawable.button_red_kepu2);
                kepu_womam.setBackgroundResource(R.drawable.button_white_kepu1);
                kepu_womam.setText("女性检查项目");
                kepu_womam.setTextColor(getResources().getColor(R.color.sys_fen));
                kepu_mam.setText("男性检查项目");
                kepu_mam.setTextColor(getResources().getColor(R.color.white));
                break;
            case R.id.kepu_activity_back:
                finish();
                break;
        }
    }

    public void replace(Fragment fragment) {
        FragmentManager fm = getSupportFragmentManager();
        FragmentTransaction ft = fm.beginTransaction();
        ft.replace(R.id.kepu_activity_ll, fragment);
        ft.commitAllowingStateLoss();
    }
}
